<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>GEN20</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="ScoregensTop.html" title="Score Statements and GEN Routines" />
    <link rel="prev" href="GEN19.html" title="GEN19" />
    <link rel="next" href="GEN21.html" title="GEN21" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">GEN20</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="GEN19.html">Prev</a> </td>
          <th width="60%" align="center">Score Statements and GEN Routines</th>
          <td width="20%" align="right"> <a accesskey="n" href="GEN21.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="GEN20"></a>
      <div class="titlepage"></div>
      <a id="IndexGEN20" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">GEN20</span>
        </h2>
        <p>GEN20 — 
      Generates functions of different windows.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp214804784"></a>
        <h2>Description</h2>
        <p>
      This subroutine generates functions of different windows. These windows are usually used for spectrum analysis or for grain envelopes.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp214806128"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>f</strong></span> # time size 20 window max [opt]</pre>
      </div>
      <div class="refsect1">
        <a id="idp214882432"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>size</em></span> -- number of points in the table. Must be a power of 2 ( + 1).
    </p>
        <p>
      <span class="emphasis"><em>window</em></span> -- Type of window to generate:

      </p>
        <div class="itemizedlist">
          <ul class="itemizedlist" style="list-style-type: disc; ">
            <li class="listitem">
              <p>1 = Hamming</p>
            </li>
            <li class="listitem">
              <p>2 = Hanning</p>
            </li>
            <li class="listitem">
              <p>3 = Bartlett ( triangle)</p>
            </li>
            <li class="listitem">
              <p>4 = Blackman ( 3-term)</p>
            </li>
            <li class="listitem">
              <p>5 = Blackman - Harris ( 4-term)</p>
            </li>
            <li class="listitem">
              <p>6 = Gaussian</p>
            </li>
            <li class="listitem">
              <p>7 = Kaiser</p>
            </li>
            <li class="listitem">
              <p>8 = Rectangle</p>
            </li>
            <li class="listitem">
              <p>9 = Sync</p>
            </li>
          </ul>
        </div>
        <p>
    </p>
        <p>
      <span class="emphasis"><em>max</em></span> -- For negative p4 this will be the absolute 
      value at window peak point. If p4 is positive or p4 is negative
      and p6 is missing the table will be post-rescaled to a maximum
      value of 1. 
    </p>
        <p>
      <span class="emphasis"><em>opt</em></span> -- Optional argument required by the 
      Gaussian window and the Kaiser window.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp214894272"></a>
        <h2>Examples</h2>
        <p>
      </p>
        <div class="informalexample">
          <pre class="programlisting">
<span class="stamnt">f</span>       1       0       1024    20      5</pre>
        </div>
        <p>

      This creates a function which contains a 4 - term Blackman - Harris window with maximum value of 1.
    </p>
        <p>
      </p>
        <div class="informalexample">
          <pre class="programlisting">
<span class="stamnt">f</span>       1       0       1024    -20     2       456</pre>
        </div>
        <p>

      This creates a function that contains a Hanning window with a maximum value of 456.
    </p>
        <p>
      </p>
        <div class="informalexample">
          <pre class="programlisting">
<span class="stamnt">f</span>       1       0       1024    -20     1</pre>
        </div>
        <p>

      This creates a function that contains a Hamming window with a maximum value of 1.
    </p>
        <p>
      </p>
        <div class="informalexample">
          <pre class="programlisting">
<span class="stamnt">f</span>       1       0       1024    20      7       1       2</pre>
        </div>
        <p>

      This creates a function that contains a Kaiser window with a maximum value of 1. The extra argument specifies how "open" the window is, for example a value of 0 results in a rectangular window and a value of 10 in a Hamming like window.
    </p>
        <p>
      </p>
        <div class="informalexample">
          <pre class="programlisting">
<span class="stamnt">f</span>       1       0       1024    20      6       1       2</pre>
        </div>
        <p>

      This creates a function that contains a Gaussian window with a
      maximum value of 1.  The extra argument specifies how broad the
      window is, as the standard deviation of the curve; in this
      example the s.d. is 2.  The default value is 1.
    </p>
        <p>
      For all diagrams, see <a class="link" href="MiscWindows.html" title="Appendix F. Window Functions"><em class="citetitle">Window Functions</em></a>
    </p>
        <p>
      Here is an example of the GEN20 routine. It uses the file <a class="ulink" href="examples/gen20.csd" target="_top"><em class="citetitle">gen20.csd</em></a>.

           </p>
        <div class="example">
          <a id="idp214909808"></a>
          <p class="title">
            <strong>Example 1110. Example of the GEN20 routine.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
 
<span class="comment">; Select audio/midi flags here according to platform </span>
-odac     <span class="comment">;;;realtime audio out </span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too </span>
<span class="comment">; For Non-realtime ouput leave only the line below: </span>
<span class="comment">; -o gen20.wav -W ;;; for file output any platform </span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
 

<span class="ohdr">sr</span> <span class="op">=</span> 44100 
<span class="ohdr">ksmps</span> <span class="op">=</span> 32 
<span class="ohdr">nchnls</span> <span class="op">=</span> 2 
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1 

<span class="oblock">instr</span> 1 

insnd   <span class="op">=</span> 10 				<span class="comment">;"fox.wav"</span>
ibasfrq <span class="op">=</span> 44100 <span class="op">/</span> <span class="opc">ftlen</span>(insnd)		<span class="comment">;use original sample rate of insnd file </span>

kamp   <span class="opc">expseg</span> .001, p3<span class="op">/</span>2, .7, p3<span class="op">/</span>2, .8	<span class="comment">;envelope</span>
kpitch <span class="opc">line</span> ibasfrq, p3, ibasfrq <span class="op">*</span> .8 
kdens  <span class="opc">line</span> 600, p3, 10 
kaoff  <span class="opc">line</span> 0, p3, .1
kpoff  <span class="opc">line</span> 0, p3, ibasfrq <span class="op">*</span> .5 
kgdur  <span class="opc">line</span> .04, p3, .001		<span class="comment">;shorten duration of grain during note</span>
imaxgdur <span class="op">=</span>  .5 
igfn <span class="op">=</span> p4 				<span class="comment">;different windows</span>
asigL  <span class="opc">grain</span> kamp, kpitch, kdens, kaoff, kpoff, kgdur, insnd, igfn, imaxgdur, 0.0 
asigR  <span class="opc">grain</span> kamp, kpitch, kdens, kaoff, kpoff, kgdur, insnd, igfn, imaxgdur, 0.0 
       <span class="opc">outs</span> asigL, asigR

<span class="oblock">endin</span> 
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
 
<span class="stamnt">f</span>1  0 512  20 2		<span class="comment">;Hanning window </span>
<span class="stamnt">f</span>2  0 512  20 6 1	<span class="comment">;Gaussian window </span>
<span class="stamnt">f</span>10 0 16384 1 "<span class="stamnt">f</span>ox.wav" 0 0 0 

<span class="stamnt">i</span>1 0 5 1		<span class="comment">;use Hanning window </span>
<span class="stamnt">i</span>1 + 5 2		<span class="comment">;use Gaussian window</span>
<span class="stamnt">e</span> 
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />  
        <span class="phrase">These are the diagrams of the waveforms of the GEN20 routines, as used in the example:</span>

      </p>
        <div class="mediaobject">
          <img src="images/gen20_1.png" alt="f 1 0 512 20 2 - Hanning window" />
          <div class="caption">
            <p>  f 1  0 512 20 2 - Hanning window</p>
          </div>
        </div>
        <p>

      </p>
        <div class="mediaobject">
          <img src="images/gen20_2.png" alt="f 2 0 512 20 6 1 - Gaussian window" />
          <div class="caption">
            <p>  f 2  0 512 20 6 1 - Gaussian window</p>
          </div>
        </div>
        <p>
   
    </p>
      </div>
      <div class="refsect1">
        <a id="idp214921328"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Paris Smaragdis</td>
          </tr>
          <tr>
            <td>MIT, Cambridge</td>
          </tr>
          <tr>
            <td>1995</td>
          </tr>
        </table>
        <p>
    </p>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: John ffitch</td>
          </tr>
          <tr>
            <td>University of Bath/Codemist Ltd.</td>
          </tr>
          <tr>
            <td>Bath, UK</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 3.2</p>
        <p>Optional argument to Gaussian added in 5.10</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="GEN19.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="ScoregensTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="GEN21.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">GEN19 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> GEN21</td>
        </tr>
      </table>
    </div>
  </body>
</html>
